#!/usr/bin/env node

const mysql = require('mysql2/promise');//引入数据库
console.log('hello');

//select northwind.departments table
//查询语句select * from departments;
//console log data

async function main() {
    //1. create connection to mysql
    const con = await mysql.createConnection({
        host: 'localhost',
        user: 'suziyi',
        password: 'ddd',
        database: 'northwind',
    });
    // 2.execute query
    const [rows] = await con.query('select * from departments');
    
    con.end();//关掉连接

    // 3.log result
    console.table(rows);
}

main();

